import request from '@/utils/request'
import defaultSettings from '@/settings'

export const apiUrlConfig = {
  queryUrl: `${defaultSettings.ctx.authorityApp}/s/postInfo/search`,
  exportUrl: `${defaultSettings.ctx.authorityApp}/s/postInfo/search`,
  delUrl: `${defaultSettings.ctx.authorityApp}/s/postInfo/remove`,
}

// 查询岗位列表
export function listPostInfo(query) {
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/postInfo/search`,
    method: 'get',
    params: query
  })
}

// 查询岗位详细
export function findPostInfo(postInfoId) {
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/postInfo/` + praseStrEmpty(postInfoId),
    method: 'get'
  })
}

// 新增岗位
export function addPostInfo(data) {
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/postInfo/add`,
    method: 'post',
    data: data
  })
}

// 修改岗位
export function updatePostInfo(data) {
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/postInfo/edit`,
    method: 'post',
    data: data
  })
}

// 删除岗位
export function delPostInfo(id) {
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/postInfo/remove?ids=${id}`,
    method: 'get'
  })
}

// 校验岗位编码
export function checkPostCode(data) {
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/postInfo/checkPostCodeUnique`,
    method: 'get',
    params:data
  })
}

//校验岗位名称
export function checkPostName(data) {
  delete data.createTime;
  delete data.updateTime;
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/postInfo/checkPostNameUnique`,
    method: 'get',
    params:data
  })
}

// 查询status=1(正常)岗位
export function searchPostByStatusVue() {
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/postInfo/searchPostByStatusVue`,
    method: 'get'
  })
};
// 根据用户ID查询岗位信息
export function selectPostsByUserId(userId) {
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/postInfo/selectPostsByUserId?userId=`+userId,
    method: 'get'
  })
};
